{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6e7f6ef5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import xlsxwriter\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2afab1d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "workbook = xlsxwriter.Workbook(os.path.join(os.path.abspath(''),'xlsxwriter.xlsx'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a979e9dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "worksheet = workbook.add_worksheet('制片')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "807a0f83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "worksheet.write(1,1,'测试')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4d450197",
   "metadata": {},
   "outputs": [],
   "source": [
    "workbook.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1fbc14b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "os.startfile(os.path.abspath(''))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "964bc74b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "worksheet.write(0,0,'测试')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d5251045",
   "metadata": {},
   "outputs": [],
   "source": [
    "path = os.path.join(os.path.abspath(''),'xlsxwriter1.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b8725352",
   "metadata": {},
   "outputs": [],
   "source": [
    "workbook1 = xlsxwriter.Workbook(path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "160baeb4",
   "metadata": {},
   "outputs": [
    {
     "ename": "DuplicateWorksheetName",
     "evalue": "Sheetname '人事', with case ignored, is already in use.",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mDuplicateWorksheetName\u001b[0m                    Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_18536/1211123345.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mworksheet1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mworkbook\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_worksheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'人事'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\python39\\lib\\site-packages\\xlsxwriter\\workbook.py\u001b[0m in \u001b[0;36madd_worksheet\u001b[1;34m(self, name, worksheet_class)\u001b[0m\n\u001b[0;32m    186\u001b[0m             \u001b[0mworksheet_class\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mworksheet_class\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    187\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 188\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_add_sheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mworksheet_class\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mworksheet_class\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    189\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    190\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0madd_chartsheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mchartsheet_class\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\python39\\lib\\site-packages\\xlsxwriter\\workbook.py\u001b[0m in \u001b[0;36m_add_sheet\u001b[1;34m(self, name, worksheet_class)\u001b[0m\n\u001b[0;32m    756\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    757\u001b[0m         \u001b[0msheet_index\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mworksheets_objs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 758\u001b[1;33m         \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_check_sheetname\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mworksheet\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mChartsheet\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    759\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    760\u001b[0m         \u001b[1;31m# Initialization data to pass to the worksheet.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\python39\\lib\\site-packages\\xlsxwriter\\workbook.py\u001b[0m in \u001b[0;36m_check_sheetname\u001b[1;34m(self, sheetname, is_chartsheet)\u001b[0m\n\u001b[0;32m    826\u001b[0m         \u001b[1;32mfor\u001b[0m \u001b[0mworksheet\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mworksheets\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    827\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0msheetname\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mworksheet\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 828\u001b[1;33m                 raise DuplicateWorksheetName(\n\u001b[0m\u001b[0;32m    829\u001b[0m                     \u001b[1;34m\"Sheetname '%s', with case ignored, is already in use.\"\u001b[0m \u001b[1;33m%\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    830\u001b[0m                     sheetname)\n",
      "\u001b[1;31mDuplicateWorksheetName\u001b[0m: Sheetname '人事', with case ignored, is already in use."
     ]
    }
   ],
   "source": [
    "worksheet1 = workbook.add_worksheet('人事')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "ea408d9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "worksheet1.write('D8','招人')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "ac5493b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "workbook1.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58528712",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
